//用户接口
import API from '../index.js'


//获取数据
export function get(data) {
	const url = `/regular/user/${data}`
	return API({
		url: url,
		method: 'get',
		data:data
	})
}

//注册
export function add(data){
    return API({
        url:'/regular/user/register',
        method: 'post',
        data:data
    })
}

//改
export function put(data) {
    return API({
        url: "/regular/user",
        method: 'put',
        data: data
    })
}

//删
export function del(data) {
    return API({
        url: "/regular/user",
        method: 'delete',
        data: ids
    })
}

//登录
export function login(data) {
	return API({
		url: '/regular/user/login',
		method: 'post',
		data: data
	})
}

// 验证token有效性
export function verifyToken() {
    return API({
        url: '/regular/user/verifyAuthentication',
        method: 'get',
    })
}
/*********************用户收藏******************************************/
// 用户添加收藏
export function addFavorite(data) {
	const url=`/regular/favorite/${data}`
    return API({
        url: url,
        method: 'post',
    })
}
// 取消收藏
export function delFavorite(data) {
	const url=`/regular/favorite/${data}`
    return API({
        url: url,
        method: 'delete',
        
    })
}
// 用户批量删除收藏
export function delListFavorite(data) {
    return API({
        url: '/regular/favorite',
        method: 'delete',
		data:data
    })
}

// 用户id分页查询收藏
export function FavoriteListpage(data) {
    return API({
        url: '/regular/favorite/page',
        method: 'get',
		params:data
    })
}

// 通过文章id和用户id获取收藏状态
export function Favstatus(data) {
	const url=`/regular/favorite/${data}`
    return API({
        url: url,
        method: 'get',
        
    })
}
//通过文章id获取收藏总数
export function FavCount(data) {
	const url=`/regular/favorite/count/${data}`
    return API({
        url: url,
        method: 'get',
        data: data,
    })
}

/*************************用户评论*********************************/

//添加评论
export function addComment(data) {
    return API({
        url: "/regular/comment",
        method: 'post',
        data: data,
    })
}


//评论分页查询
export function cListPage(data) {
    return API({
        url: "/regular/comment",
        method: 'get',
        params: data,
    })
}

//删除评论
export function delComment(data) {
    return API({
        url: "/regular/comment",
        method: 'delete',
        data: data,
    })
}

//修改评论
export function putComment(data) {
    return API({
        url: "/regular/comment",
        method: 'put',
        params: data,
    })
}

/*****************分类获取*********************/
//列表
export function getcategory(data) {
    return API({
        url: "/regular/category",
        method: 'get',
        params: data,
    })
}

//根据id获取列表
export function getcatById(data) {
	const url=`/regular/category/${data}`
    return API({
        url: url,
        method: 'get',
        params: data,
    })
}
/***********标签获取********/
export function gettag(data) {
    return API({
        url: "/regular/tag",
        method: 'get',
        params: data,
    })
}
